package com.quaidi.smartlocker.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.quaidi.smartlocker.entity.ExpressCompany;
import com.quaidi.smartlocker.mapper.ExpressCompanyMapper;
import com.quaidi.smartlocker.service.ExpressCompanyService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 快递公司Service实现类
 * 
 * @author QuaiDi
 * @since 2025-08-26
 */
@Service
public class ExpressCompanyServiceImpl extends ServiceImpl<ExpressCompanyMapper, ExpressCompany> implements ExpressCompanyService {

    @Override
    public List<ExpressCompany> getAllActiveCompanies() {
        LambdaQueryWrapper<ExpressCompany> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ExpressCompany::getStatus, 1)
                   .orderByAsc(ExpressCompany::getCompanyName);
        return list(queryWrapper);
    }

    @Override
    public ExpressCompany getByCompanyCode(String companyCode) {
        LambdaQueryWrapper<ExpressCompany> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ExpressCompany::getCompanyCode, companyCode)
                   .eq(ExpressCompany::getStatus, 1);
        return getOne(queryWrapper);
    }
}